<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/token.jsp"%>
<%
    Integer pid = input.getInt("pid", -1);
    String imgs = input.getDesc("imgs", "");
    List<UserProfile> userProfiles = QBuilder.db("basedb").select().from("UserProfile").where(new Where("hospital=", hospital).and("status = ", STATUS_ENABLE).and("id=", pid).and("uid=", token.getUid())).query().getResultObj();
    if (userProfiles.size() == 0) {
        Tools.encryptPrint(out, new Message(30041, "没有该用户"));
        return;
    }
    UserProfile up = userProfiles.get(0);
    Orthopedics orthopedics = Orthopedics.fromMap(parameters, Orthopedics.class);
    orthopedics.setUserId(pid);
    orthopedics.setName(up.getName());
    orthopedics.setGender(up.getGender());
    orthopedics.setAge(up.getAge());
    orthopedics.setPhone(up.getPhone());
    orthopedics.setCategory(1);
    if (!"".equals(imgs)) {
        String[] strs = imgs.split("\\|");
        List<Map> imgsMap = new ArrayList<Map>();
        for (int i = 0; i < strs.length; i++) {
            Map _map = new HashMap();
            _map.put("src", strs[i]);
            imgsMap.add(_map);
        }
        orthopedics.setImg(JSONUtil.toJson(imgsMap));
    }
    Integer id = (Integer)DBTools.db("basedb").addItem(orthopedics);
    if (id == null) {
        msg = new Message(30001, "上传失败");
    }
    msg.put("data", id);
    Tools.encryptPrint(out, msg);
%>
